Global Index
HTML5 JS API Index > ECMAScript Tutorials & Specs

Math

The Math object is a single object that has some named properties, some of which are functions.

Properties
const number
E = 2.7182818284590452354
The Number value for e, the base of the natural logarithms, which is approximately 2.7182818284590452354.
const number
LN10 = 2.302585092994046
The Number value for the natural logarithm of 10, which is approximately 2.302585092994046.
const number
LN2 = 0.6931471805599453
The Number value for the natural logarithm of 2, which is approximately 0.6931471805599453.
const number
LOG10E = 0.4342944819032518
The Number value for the base-10 logarithm of e, the base of the natural logarithms; this value is approximately 0.4342944819032518.
const number
LOG2E = 1.4426950408889634
The Number value for the base-2 logarithm of e, the base of the natural logarithms; this value is approximately 1.4426950408889634.
const number
PI = 3.1415926535897932
The Number value for π, the ratio of the circumference of a circle to its diameter, which is approximately 3.1415926535897932.
const number
SQRT1_2 = 0.7071067811865476
The Number value for the square root of ½, which is approximately 0.7071067811865476.
const number
SQRT2 = 1.4142135623730951
The Number value for the square root of 2, which is approximately 1.4142135623730951.
Operations
static number
abs(number x)
Returns the absolute value of x; the result has the same magnitude as x but has positive sign.
static number
acos(number x)
Returns an implementation-dependent approximation to the arc cosine of x. The result is expressed in radians and ranges from +0 to +π.
static number
asin(number x)
Returns an implementation-dependent approximation to the arc sine of x. The result is expressed in radians and ranges from −π/2 to +π/2.
static number
atan(number x)
Returns an implementation-dependent approximation to the arc tangent of x. The result is expressed in radians and ranges from −π/2 to +π/2.
static number
atan2(number y, number x)
Returns an implementation-dependent approximation to the arc tangent of the quotient y/x of the arguments y and x, where the signs of y and x are used to determine the quadrant of the result. Note that it is intentional and traditional for the two-argument arc tangent function that the argument named y be first and the argument named x be second.
static number
ceil(number x)
Returns the smallest (closest to −∞) Number value that is not less than x and is equal to a mathematical integer. If x is already an integer, the result is x.
static number
cos(number x)
Returns an implementation-dependent approximation to the cosine of x. The argument is expressed in radians.
static number
exp(number x)
Returns an implementation-dependent approximation to the exponential function of x (e raised to the power of x, where e is the base of the natural logarithms).
static number
floor(number x)
Returns the greatest (closest to +∞) Number value that is not greater than x and is equal to a mathematical integer. If x is already an integer, the result is x.
static numberlog(number x)
static number
max(number values...)
Given zero or more arguments, calls ToNumber on each of the arguments and returns the largest of the resulting values.
static number
min(number values...)
Given zero or more arguments, calls ToNumber on each of the arguments and returns the smallest of the resulting values.
static number
pow(number x, number y)
Returns an implementation-dependent approximation to the result of raising x to the power y.
static number
random()
Returns a Number value with positive sign, greater than or equal to 0 but less than 1, chosen randomly or pseudo randomly with approximately uniform distribution over that range, using an implementation-dependent algorithm or strategy. This function takes no arguments.
static number
round(number x)
Returns the Number value that is closest to x and is equal to a mathematical integer. If two integer Number values are equally close to x, then the result is the Number value that is closer to +∞. If x is already an integer, the result is x.
static number
sin(number x)
Returns an implementation-dependent approximation to the sine of x. The argument is expressed in radians.
static number
sqrt(number x)
Returns an implementation-dependent approximation to the square root of x.
static number
tan(number x)
Returns an implementation-dependent approximation to the tangent of x. The argument is expressed in radians.